package com.activitycode.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckedTextView;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;

import com.activitycode.activity.find.searchlimit.OtherChooseEntity;
import com.duostec.zhuyue.pets.R;

public class SearchOtherApapter extends BaseAdapter {
	private List<OtherChooseEntity> list;
	private Context context;

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return position;
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	public SearchOtherApapter(List<OtherChooseEntity> list, Context context) {
		this.list = list;
		this.context = context;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		ViewHolder viewHolder;
		if (convertView == null) {
			convertView = LayoutInflater.from(context).inflate(
					R.layout.adapter_chooselimit, null);
			viewHolder = new ViewHolder();

			viewHolder.cTextView = (TextView) convertView
					.findViewById(R.id.limittext);	
			viewHolder.cImageView = (ImageView) convertView
					.findViewById(R.id.limitimage);
			
			
			convertView.setTag(viewHolder);
		} else {
			viewHolder = (ViewHolder) convertView.getTag();
		}

		viewHolder.cTextView.setText(list.get(position).getName());
		viewHolder.cImageView.setImageResource(R.drawable.check);
		if(list.get(position).getChecked()){
			viewHolder.cImageView.setVisibility(View.VISIBLE);
		}else {
			viewHolder.cImageView.setVisibility(View.GONE);
		}
			
		
		return convertView;
	}
		public final static class ViewHolder {
			private TextView cTextView;
			private ImageView cImageView;

		}

	
}
